package com.ph.website.home.controller;

import com.ph.website.home.base.common.CommonResult;
import com.ph.website.home.param.NewsParam;
import com.ph.website.home.service.INewsService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

@RestController
@RequestMapping("/api/news")
public class NewsController {

    @Resource
    private INewsService newsService;


    /**后台分页查询新闻列表*/
    @RequestMapping("/list")
    public CommonResult list(@Valid NewsParam.ListParam param){
        return newsService.list(param);
    }

    /**提交审核*/
    @RequestMapping("/verify")
    public CommonResult verify(@Valid NewsParam.VerifyParam param){
        return newsService.verify(param);
    }

    /**删除*/
    @RequestMapping("/delete")
    public CommonResult delete(@Valid NewsParam.DeleteParam param){
        return newsService.delete(param);
    }

    /**发布*/
    @RequestMapping("/publish")
    public CommonResult publish(@Valid NewsParam.PublishParam param){
        return newsService.publish(param);
    }

    /**驳回*/
    @RequestMapping("/reject")
    public CommonResult reject(@Valid NewsParam.RejectParam param){
        return newsService.reject(param);
    }

    /**取消发布*/
    @RequestMapping("/unPublish")
    public CommonResult unPublish(@Valid NewsParam.UnPublishParam param){
        return newsService.unPublish(param);
    }

    /**新增新闻*/
    @RequestMapping("/add")
    public CommonResult add(@Valid NewsParam.AddParam param){
        return newsService.add(param);
}

    /**修改新闻*/
    @RequestMapping("/modify")
    public CommonResult modify(@Valid NewsParam.ModifyParam param){
        return newsService.modify(param);
    }

    /**获取新闻*/
    @RequestMapping("/get")
    public CommonResult get(@Valid NewsParam.GetParam param){
        return newsService.get(param);
    }
}
